﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Trying1.Classes;

namespace Trying1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class Login : Window
    {
        public Login()
        {
            InitializeComponent();
        }
        private void btnMin_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
            SystemCommands.MinimizeWindow(this);
        }

        private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
            this.Close();
        }
		private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
    		DragMove();
		}

		private void btnLogin_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			// TODO: Add event handler implementation here.
            if (tbxUsername.Text != "" && tbxPassword.Password != "")
            {
                LoginInfo.Username = tbxUsername.Text;
                LoginInfo.Password = tbxPassword.Password;
                Staff m = StaffDBManager.GetStaffByUsername(LoginInfo.Username);
                if (LoginInfo.Password.Equals(m.password))
                {
                    this.Hide();
                    if (m.StaffType.Equals("Administrator"))
                    {
                        AdminForm objAdminForm = new AdminForm();
                        objAdminForm.Show();
                    }
                    else if (m.StaffType.Equals("Receptionist"))
                    {
                        
                            ReceptionForm objReceptionForm = new ReceptionForm();
                            objReceptionForm.Show();
                        
                        
                    }
                    else if (m.StaffType.Equals("Management"))
                    {
                        ManagementForm objMgmtForm = new ManagementForm();
                        objMgmtForm.Show();
                    }

                }
                else
                {
                    lblResult.Content = "Login Username or Password is invalid!";
                    LoginInfo.Username = null;
                    LoginInfo.Password = null;
                }
            }
            else
            {
                lblResult.Content = "Please enter a Username and Password!";
            }

		}

        private void btnCloseCopy_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void btnMinCopy_Click(object sender, RoutedEventArgs e)
        {
            SystemCommands.MinimizeWindow(this);
        }
    }
}
